import axios from "@/api/config"
import {isThree} from '@/assets/js/utils';

//独立机构树
export async function independentData() { 
    const url = '/ssm/root/unit/list';
    let res = await axios.get(url);
    return res;
}
//从缓存中获取所有单位(独立机构)
export async function cacheIndependent() { 
    const url = '/ssm/root/unit/list/all';
    let res = await axios.get(url);
    return res;
}
//根据条件获取菜单
export async function menuByCondition(data) {
    const url = '/ssm/menu/tree/list?hasSeparate='+(data.hasSeparate===undefined?isThree:data.hasSeparate)+'&hasButton='+data.hasButton+'&rootId='+data.rootId;
    let res = await axios.get(url);
    return res;
}


//获取工作组树
export async function worksTree() { //工作组
    const url = '/ssm/team/root/tree/list';
    let res = await axios.get(url);
    return res;
}
//获取工作组树

//获取部门树
export async function unitTree() { //部门树
    const url = '/ssm/unit/tree/list';
    let res = await axios.get(url);
    return res;
}
//获取部门树
//从缓存中获取独立机构下所有部门树
export async function cacheUnit() {
    const url = '/ssm/unit/root/all/unit';
    let res = await axios.get(url);
    return res;
}

//选择机构弹窗接口 开始
// 机构用户选择首页数据列表
export const selectData = data=>axios.post('/ssm/select/user/group/list',data);
//获取用户列表
export const selectUser = data=>axios.post('/ssm/select/user/list',data);
//获取查询结果
export const userSearch = data=>axios.post('/ssm/select/user/search',data);
//选择机构弹窗接口 结束

//获取字典项  用户密级
export async function getParams (data){
    const url = encodeURI('/ssm/param/get/all?typeName='+data);
    let res = await axios.get(url);
    return res;
}